package cn.stimd.spring.validation;

/**
 * 封装了一个字段错误，即指定字段访问失败的原因
 * <p>
 * Created by Stimd
 * 项目地址：https://gitee.com/stimd/spring-wheel
 * 公众号：Java编程探微
 */
public class FieldError extends ObjectError {
    private final String field;             //字段名
    private final Object rejectedValue;     //未绑定成功的值
    private final boolean bindingFailure;   //是否绑定失败

    public FieldError(String objectName, String field, Object rejectedValue, boolean bindingFailure, String code, String defaultMessage) {
        super(objectName, code, defaultMessage);
        this.field = field;
        this.rejectedValue = rejectedValue;
        this.bindingFailure = bindingFailure;
    }

    public String getField() {
        return field;
    }

    public Object getRejectedValue() {
        return rejectedValue;
    }

    public boolean isBindingFailure() {
        return bindingFailure;
    }
}
